package me.ratel.demo.eBook.interfaces.ordering.web;

import com.alibaba.fastjson.JSON;
import me.ratel.demo.eBook.infrastructure.exceptions.BusinessException;
import me.ratel.demo.eBook.infrastructure.utils.XmlUtils;
import me.ratel.demo.eBook.interfaces.ordering.dto.OrderNotifyResponseDto;
import me.ratel.demo.eBook.interfaces.utils.ResponseUtil;
import me.ratel.demo.eBook.interfaces.web.WebConstants;
import me.ratel.demo.eBook.interfaces.web.WebError;
import me.ratel.demo.wechat.entities.BrandWCPayRequest;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @author Administrator
 * @time 2016/9/23 22:16
 */
@Controller
public class OrderingController {
    private static final Logger logger = LoggerFactory.getLogger(OrderingController.class);

    @RequestMapping("/order/notify") public void notifyOrder(HttpServletRequest request, HttpServletResponse response) {
        OrderNotifyResponseDto responseDto = null;
        try {
            responseDto = new OrderNotifyResponseDto("SUCCESS", "OK");
        } catch (BusinessException bize) {
            logger.info("/order/notify 业务异常", bize);
        } catch (Throwable t) {
            logger.info("/order/notify 系统异常", t);
        }
        logger.info("/order/notify 返回 [{}]", XmlUtils.toXML(responseDto));

        ResponseUtil.writeXML(response, responseDto);
    }
}
